// McNetHandler.h: interface for the McNetHandler class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MCNETHANDLER_H__4E03A739_4331_48DC_9886_F73375991517__INCLUDED_)
#define AFX_MCNETHANDLER_H__4E03A739_4331_48DC_9886_F73375991517__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "../McAsyncSocket.h"

class McNetHandler : public McAsyncSocketHandler
{
	virtual int after_open();
	virtual int after_read_frame(const char* data, long length);
public:
	McNetHandler();
	virtual ~McNetHandler();
};

class McNetConnector : public ACE_Asynch_Connector<McNetHandler>
{
	virtual void handle_time_out (const ACE_Time_Value &current_time, const void *act = 0);
	virtual int validate_connection(const ACE_Asynch_Connect::Result& result, const ACE_INET_Addr &remote, const ACE_INET_Addr& local);
	
	long timer_id_;
public:
	McNetConnector();
	void reconnect();
	void close (void);
	ACE_INET_Addr addr_;
	McNetHandler* handler_;
	long reconnect_timerout_;
};

typedef ACE_Unmanaged_Singleton<McNetConnector, ACE_Null_Mutex> NET_CONNECTOR;


#endif // !defined(AFX_MCNETHANDLER_H__4E03A739_4331_48DC_9886_F73375991517__INCLUDED_)
